var page = require('webpage').create(); 
var args = require('system').args; 
  
var url = args[1]; 
var filename = args[2];

page.paperSize = {
    format: 'A4', //A4 纸张
    orientation: 'portrait',
    //设置页边距 取消会出现灰边
    margin: {
        top: '20px',
        left: '40px',
        bottom: '20px',
        right: '40px',
    }
};
page.zoomFactor = 1;//放大比例
page.open(url, function () {
	setTimeout(function(){
  page.render(filename); 
  phantom.exit(); 
	},5000)
});


/*
page.open(url, function (status) {
        if (status !== 'success') {
            console.log('Unable to load the address!');
            phantom.exit(1);
        }else{
            console.log('able to load the address!');
            window.setTimeout(function () {
                page.render(filename);
         page.render('jietu_6.png');
//                phantom.exit();
  console.log('asd')
            }, 1000);
            window.setInterval(function () {
                page.render(filename);
         //page.render('jietu_8.png');
 phantom.exit();
  //console.log('111asd')
            }, 5000);
        }
    });



page.open(url, function (status) 
{

    if (status != "success") 
    {
        console.log('FAIL to load the address');
        phantom.exit();
    }
    
    page.evaluate(function()
    {
        //�˺�����Ŀ��ҳ��ִ�еģ������Ļ����Ǳ�phantomjs�����Բ����õ����js����������
        
  setTimeout(function(){
	        page.render(filename);
        phantom.exit();
  },"5000");    
    


});

*/
